package ca.tatham.senssim;

import java.io.BufferedWriter;
import java.io.FileWriter;

public class MemoryUsage
{

  public static void main(String[] args) throws Exception
  {
    BufferedWriter writer = new BufferedWriter(new FileWriter(
        "memoryByNode.csv"));

    for (int neighbors = 0; neighbors < 100; neighbors++)
    {
      int sinks = 1;
      // for (int sinks = 0; sinks < 50; sinks++)
      // {
      writer.write(Integer.toString(neighbors));
      writer.write(',');
      writer.write(Integer.toString(sinks));
      writer.write(',');
      writer.write(getDdMemory(neighbors, sinks));
      writer.write(',');
      writer.write(getPdddMemory(neighbors, sinks));
      writer.newLine();
      // }
    }
    writer.close();
  }

  private static String getPdddMemory(int num, int sinks)
  {
    int sinkInfo = 12 + 8 + 4 + 4 * num + 4;
    int ackTimers = num / 2 * 12;
    return Integer.toString(sinkInfo * sinks + ackTimers);
  }

  private static String getDdMemory(int num, int sinks)
  {
    int gradient = 20;
    int timers = num / 2 * 12;
    return Integer.toString(gradient + timers);
  }

}
